using System;

namespace Sedna.Core.Persistence
{
	/// <summary>
	/// this attribute allows a developer to mark a particular method as being sessional.
	/// In this case the <see cref="PstInterceptor"/> will ensure that a valid session is open
	/// (if this is not the case, HbmInterceptor opens one), and if a component implements the 
	/// <see cref="ISessionAware"/> interface injects that session into the component.
	/// However, if a component exposes the <see cref="ISessionAware"/> interface, all methods 
	/// intercepted by HbmInterceptor are considered to be marked with this attribute, thus a session
	/// will be opened (or joined) and be injected into the component.
	/// 
	/// Nevertheless, the developers are still encouraged to use this attribute to mark the 
	/// sessional methods, i.e. methods that imply some interaction with the underlying DB.
	/// This raises up the overall code style and comprehension.
	/// </summary>
	[AttributeUsage(AttributeTargets.Method)]
	public class SessionalAttribute : Attribute
	{
        private bool closeNewSession = true;

	    public SessionalAttribute()
	    {
	    }

	    public SessionalAttribute(bool closeNewSession)
	    {
	        this.closeNewSession = closeNewSession;
	    }

	    public bool CloseNewSession
	    {
	        get { return closeNewSession; }
	    }
	}
}
